chrome.contextMenus.create({
    "title": "随手记", "contexts":
        ["page", "selection", "link", "editable", "image", "video",
            "audio"], "onclick": genericOnClick
});

function genericOnClick(info, tab) {
    var xhr = new XMLHttpRequest();

    //alert(JSON.stringify(tab));
    var url = 'http://ui11.hfjava.com/biji/add';
    xhr.open('POST', url, true);
    xhr.setRequestHeader("Content-Type", "application/json;charset=utf-8");


    xhr.onreadystatechange = function() {
       // alert(JSON.stringify(xhr));
        if (xhr.readyState == 4) {
            if (xhr.status == 200) {
                //alert(xhr.responseText)
            } else {
                alert("发生错误！")
            }
        }
    }

    var bijidata = {
        "biJiUser": {
            "id": 121
        },
        "content": info.selectionText,
        "contextTxt": info.selectionText,
        "createDate": new Date().toLocaleString(),
        "title": tab.title
    };

    xhr.send(JSON.stringify(bijidata));

}


